<!doctype html>
<html>
<head>
    <meta name="Generator"  />
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <title>评价</title>
    <meta name="Keywords" content="Call管家" />
    <meta name="Description" content="Call管家" />
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>

    <link rel="stylesheet" href="__HOMECSS__/style.css">
    
</head>

<body style="overflow: hidden;">

<div class="evaluate_top">
    <span>商品评价</span>
    <div id="star">
        <ul>
            <li><a href="javascript:;">1</a></li>
            <li><a href="javascript:;">2</a></li>
            <li><a href="javascript:;">3</a></li>
            <li><a href="javascript:;">4</a></li>
            <li><a href="javascript:;">5</a></li>
        </ul>
        <span></span>
        <p></p>
    </div>
</div>
<div class="evaluate_content">
    <form method="post">
        <div class="message">
            <textarea placeholder="快告诉小伙伴宝贝有多好吧，大家等着我的使用心得呢~" name="comment" id="comment"></textarea>
            <input type="hidden" id="star_input" name="star" >
        </div>
        <div class="address_new">
            <p id="submit">提交</p>
        </div>
    </form>
</div>
</body>

<script src="__HOMEJS__/jquery-1.7.2.min.js"></script>
<script src="__PUBLIC__/layer/layer.js"></script>
<script type="text/javascript">
    window.onload = function (){
        var oStar = document.getElementById("star");
        var aLi = oStar.getElementsByTagName("li");
        var oUl = oStar.getElementsByTagName("ul")[0];
        var oSpan = oStar.getElementsByTagName("span")[1];
        var oP = oStar.getElementsByTagName("p")[0];
        var i = iScore = iStar = 0;
        for (i = 1; i <= aLi.length; i++){
            aLi[i - 1].index = i;
            //鼠标移过显示分数
            aLi[i - 1].onmouseover = function (){
                fnPoint(this.index);
                //浮动层显示
                oP.style.display = "block";
                //计算浮动层位置
                oP.style.left = oUl.offsetLeft + this.index * this.offsetWidth - 104 + "px";
            };
        }
        
        //评分处理
        function fnPoint(iArg){
            //分数赋值
            iScore = iArg || iStar;
            for (i = 0; i < aLi.length; i++) aLi[i].className = i < iScore ? "on" : "";
            $('#star_input').val($('#star .on').length);
        }

        $('#submit').click(function(){
            if(!$('#comment').val() || !$('#star_input').val()){
                layer.msg('请完善评价');return;
            }
            $('form').submit();
        });
    };
</script>
</html>
